<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="com.ignou.mca.beans.UserVO"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.ignou.mca.beans.QuestionsBean"%>
<%@page import="java.util.StringTokenizer"%>
<%@page import="java.util.Iterator"%>
<%@page import="com.ignou.mca.beans.ExamBean"%>
<%@page import="com.ignou.mca.datasource.DatabaseOperations"%><html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="theme/style.css"
	media="screen" />
<title>OES - Displaying examination</title>
</head>
<body onload="userfocus()">
	<div id="MainWrapper">
		<div id="MainContent">
		<h2>Displaying Exam</h2>
		<%
			UserVO uvo = (UserVO) session.getAttribute("UserVO");
			if(uvo==null)
			{
				response.sendRedirect("./Login.jsp");
			}
			else
			{
				String e = request.getParameter("exam");
				int examId = 0;
				if(e!=null)
				{
					examId = Integer.parseInt(e);					
				}
				%>
				<table>
			<%
				DatabaseOperations dbOperations = new DatabaseOperations();
				ArrayList<QuestionsBean> ques = dbOperations.viewExamPaper(examId);
				if(ques.size()>0)
				{
					Iterator<QuestionsBean> itr = ques.iterator();
					int quesNo = 1;
					while(itr.hasNext()) 
					{
						QuestionsBean qb = (QuestionsBean)itr.next();
						%>
						<tr><td>Question:<%=quesNo %></td><td><b><%=qb.getQuestion() %></b></td></tr>
						<%	
							ArrayList<String> st = qb.getOptions();
							Iterator it = st.iterator();
							while(it.hasNext()) 
							{
								String option = (String) it.next();
								out.println("<tr><td></td><td><input type='radio' name='option"+quesNo+"' value='" + option+"'>" + option+"</input></td></tr>");
							}
						%>
						<tr><td></td><td></td></tr>
						<%
						quesNo++;
					}
				}else
				{
					
				}
			}
		%>
		</table>	
		</div>
	</div>
</body>
</html>